<template>
    <div>
        <TopBar title="我的"></TopBar>
        <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
        <!-- <Table></Table>
        <Table2></Table2> -->
        <van-cell title="姓名：" :value="name"/>
        <van-cell title="企业：" :value="corp"/>
        <van-cell title="身份：" :value="role"/>
        <van-cell title="工号：" :value="id"/>
        <van-cell title="组号：" :value="group"/>
        <el-button type="primary" round @click="logout">退出登录</el-button>
        <br><br>
        <el-button type="primary" round @click="updateForm">更改工单</el-button>  <!--供开发用-->
        <br><br>
        <el-button type="primary" round @click="updateMaintain">更改分配</el-button>  <!--供开发用-->

        <dark-model-page></dark-model-page>

    </div>
</template>

<script>
import TopBar from "@/components/TopBar";
import DarkModelPage from '../DarkModelPage.vue';

export default {
    // eslint-disable-next-line vue/multi-word-component-names
    name: "index",
    data(){
        return{
            name: '',
            corp: '广州市鸿成机械轴承有限公司',
            role: '',
            id: sessionStorage.id,
            group: ''
        }
    },
    components: {
        TopBar,
        DarkModelPage,
    },
    methods: {
        logout(){
            sessionStorage.removeItem('role')
            sessionStorage.removeItem('id')
            sessionStorage.removeItem('logined')
            sessionStorage.removeItem('current')
            this.$router.push('/login')
        },
        updateForm(){
            this.$router.push('/updateForm')
        },
        updateMaintain(){
            this.$router.push('/updateMaintain')
        }
    },
    mounted(){
        const current = JSON.parse(sessionStorage.current);
        // console.log(current)
        this.name = current.name;
        this.role = current.role;
        this.group = current.group;
        switch (current.role){
            case 0:
                this.role = 'boss';
                break;
            case 1:
                this.role = 'leader';
                break;
            case 2:
                this.role = 'maintainer';
                break;
            case 3:
                this.role = 'monitor';
                break;
        }
    }
}
</script>

<style scoped>

</style>
